package com.emep.changzhi.analyse.http.statistics;


import com.emep.changzhi.analyse.model.ResultBean;
import com.emep.changzhi.analyse.service.statistics.AnnualTotalEmissionsService;
import com.emep.changzhi.analyse.utils.Constant;
import com.emep.changzhi.analyse.utils.DataValidator;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("annua")
@Api(value="年度排放量统计controller",tags={"年度排放量统计"})
public class AnnualTotalEmissionsController {

    private AnnualTotalEmissionsService service;

    /**
     * 年度排放量统计
     * @param payload
     * @return
     */
    @ApiOperation(value="年度排放量统计", notes="年度排放量统计")
    @ApiResponses({ @ApiResponse(code = 1, message = "操作成功"),
            @ApiResponse(code = 0, message = "操作失败，服务器内部异常"),
            @ApiResponse(code = 303, message = "权限不足") })

    @GetMapping(value = "list")
    public ResultBean<Integer> rankingSites(@RequestParam Map<String, Object> payload){
        ResultBean result = DataValidator.validateMapData(payload);

        if (result.getCode() == Constant.RESULT_CODE_SUCCESS) {
            return result.ok(service.getlist());
        }
        return result;
    }

}
